/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/** *****************************************************************************************************
 *  \file     Mcu_ResetSig.h                                                                            *
 *  \brief    This file contains interface header for MCU MCAL driver                                   *
 *                                                                                                      *
 * <table>                                                                                              *
 * <tr><th>Date           <th>Version                                                                   *
 * <tr><td>2023/09/09     <td>1.0.0                                                                     *
 * </table>                                                                                             *
 *******************************************************************************************************/

#ifndef MCU_RESETSIG_H
#define MCU_RESETSIG_H
/********************************************************************************************************
 *                                      Include header files                                            *
 *******************************************************************************************************/
#include "Mcu_GeneralTypes.h"
/********************************************************************************************************
 *                                 Global Macro definition                                              *
 *******************************************************************************************************/
#define MCU_RESET_CORE     1U
#define MCU_RESET_LATENT   2U
#define MCU_RESET_MISSION  3U
#define MCU_RESET_MODULE   4U
#define MCU_RESET_IST      5U
#define MCU_RESET_DEBUG    6U

#define MCU_RESET_TYPE_SHIFT  24U

#define MCU_RESET_SIG_ID(type, idx) \
    ((uint32)((((uint32)(type)) << ((uint32)MCU_RESET_TYPE_SHIFT)) | ((uint32)(idx))))

#define MCU_RESET_TYPE(id)   ((uint32)(((uint32)(id)) >> ((uint32)MCU_RESET_TYPE_SHIFT)))
#define MCU_RESET_INDEX(id)  ((uint32)(((uint32)(id)) & MCU_BIT_MASK(MCU_RESET_TYPE_SHIFT)))

#define MCU_RESET_GENERAL_REG_NUM  8U

/********************************************************************************************************
 *                                  Global Types definition                                             *
 *******************************************************************************************************/
#if (defined(E3650))
typedef enum
{
    RSTSIG_SAF_CR52P0           = MCU_RESET_SIG_ID(MCU_RESET_CORE, 0U),
    RSTSIG_SAF_CR52P1           = MCU_RESET_SIG_ID(MCU_RESET_CORE, 1U),
    RSTSIG_SAF_CR52P2           = MCU_RESET_SIG_ID(MCU_RESET_CORE, 2U),
    RSTSIG_SAF_CR52P3           = MCU_RESET_SIG_ID(MCU_RESET_CORE, 3U),
    RSTSIG_SAF_CR5_SE           = MCU_RESET_SIG_ID(MCU_RESET_CORE, 4U),
    RSTSIG_SAF_LATENT           = MCU_RESET_SIG_ID(MCU_RESET_LATENT, 0U),
    RSTSIG_SAF_MISSION0         = MCU_RESET_SIG_ID(MCU_RESET_MISSION, 0U),
    RSTSIG_SAF_MISSION1         = MCU_RESET_SIG_ID(MCU_RESET_MISSION, 1U),
    RSTSIG_SAF_MISSION2,
    RSTSIG_SAF_MISSION3,
    RSTSIG_SAF_MISSION4,
    RSTSIG_SAF_MISSION5         = MCU_RESET_SIG_ID(MCU_RESET_MISSION, 5U),
    RSTSIG_SAF_MISSION6,
    RSTSIG_SAF_MISSION7,
    RSTSIG_SAF_MISSION8,
    RSTSIG_SAF_MISSION9         = MCU_RESET_SIG_ID(MCU_RESET_MISSION, 9U),
    RSTSIG_SAF_SEIP             = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 0U),
    RSTSIG_SAF_DMA_SF1_RST0,
    RSTSIG_SAF_DMA_SF1_RST1,
    RSTSIG_SAF_DMA_SF2_RST0,
    RSTSIG_SAF_DMA_SF2_RST1,
    RSTSIG_SAF_XSPI1A           = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 5U),
    RSTSIG_SAF_XSPI1B,
    RSTSIG_SAF_VIC2,
    RSTSIG_SAF_MB,
    RSTSIG_SAF_EPWM1,
    RSTSIG_SAF_EPWM2            = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 10U),
    RSTSIG_SAF_EPWM3,
    RSTSIG_SAF_EPWM4,
    RSTSIG_SAF_ETMR1,
    RSTSIG_SAF_ETMR2,
    RSTSIG_SAF_ETMR3            = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 15U),
    RSTSIG_SAF_ETMR4,
    RSTSIG_SAF_IOC,
    RSTSIG_SAF_DPE,
    RSTSIG_SAF_XTRG1            = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 19U),
    RSTSIG_SAF_XTRG2            = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 20U),
    RSTSIG_SAF_ENET1,
    RSTSIG_SAF_ENET2,
    RSTSIG_SAF_SEHC1,
    RSTSIG_SAF_CANFD3,
    RSTSIG_SAF_CANFD4           = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 25U),
    RSTSIG_SAF_CANFD5,
    RSTSIG_SAF_CANFD6,
    RSTSIG_SAF_CANFD7,
    RSTSIG_SAF_CANFD8,
    RSTSIG_SAF_CANFD9           = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 30U),
    RSTSIG_SAF_CANFD10,
    RSTSIG_SAF_CANFD11,
    RSTSIG_SAF_CANFD12,
    RSTSIG_SAF_CANFD13,
    RSTSIG_SAF_CANFD14          = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 35U),
    RSTSIG_SAF_CANFD15,
    RSTSIG_SAF_CANFD16,
    RSTSIG_SAF_I2C2,
    RSTSIG_SAF_I2C3,
    RSTSIG_SAF_I2C4             = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 40U),
    RSTSIG_SAF_SPI3,
    RSTSIG_SAF_SPI4,
    RSTSIG_SAF_SPI5,
    RSTSIG_SAF_SPI6,
    RSTSIG_SAF_SPI7             = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 45U),
    RSTSIG_SAF_SPI8,
    RSTSIG_SAF_SPI9,
    RSTSIG_SAF_SPI10,
    RSTSIG_SAF_SPI11,
    RSTSIG_SAF_SPI12            = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 50U),
    RSTSIG_SAF_SPI13,
    RSTSIG_SAF_SPI14,
    RSTSIG_SAF_UART3,
    RSTSIG_SAF_UART4,
    RSTSIG_SAF_UART5            = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 55U),
    RSTSIG_SAF_UART6,
    RSTSIG_SAF_UART7,
    RSTSIG_SAF_UART8,
    RSTSIG_SAF_UART9,
    RSTSIG_SAF_UART10           = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 60U),
    RSTSIG_SAF_UART11,
    RSTSIG_SAF_UART12,
    RSTSIG_SAF_UART13,
    RSTSIG_SAF_UART14,
    RSTSIG_SAF_UART15           = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 65U),
    RSTSIG_SAF_UART16,
    RSTSIG_SAF_UART17,
    RSTSIG_SAF_UART18,
    RSTSIG_SAF_UART19,
    RSTSIG_SAF_UART20           = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 70U),
    RSTSIG_SAF_SENT,
    RSTSIG_SAF_ADC1,
    RSTSIG_SAF_ADC2,
    RSTSIG_SAF_ADC3,
    RSTSIG_SAF_ADC4             = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 75U),
    RSTSIG_SAF_ADC5,
    RSTSIG_SAF_ADC6,
    RSTSIG_SAF_SACI1,
    RSTSIG_SAF_MRAM1,
    RSTSIG_SAF_MRAM2            = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 80U),
    RSTSIG_SAF_MRAM3,
    RSTSIG_SAF_MRAM4            = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 82U),
    /* PRQA S 1535 1 */
} Mcu_ResetSignalSafetyType;

typedef enum
{
    RSTSIG_LP_CR5_LP            = MCU_RESET_SIG_ID(MCU_RESET_CORE, 0U),
    RSTSIG_LP_MISSION0          = MCU_RESET_SIG_ID(MCU_RESET_MISSION, 0U),
    RSTSIG_LP_MISSION1          = MCU_RESET_SIG_ID(MCU_RESET_MISSION, 1U),
    RSTSIG_LP_MISSION2          = MCU_RESET_SIG_ID(MCU_RESET_MISSION, 2U),
    RSTSIG_LP_MISSION4          = MCU_RESET_SIG_ID(MCU_RESET_MISSION, 4U),
    RSTSIG_LP_CANFD1            = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 0U),
    RSTSIG_LP_CANFD2,
    RSTSIG_LP_I2C1,
    RSTSIG_LP_SPI1,
    RSTSIG_LP_SPI2,
    RSTSIG_LP_UART1             = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 5U),
    RSTSIG_LP_UART2,
    RSTSIG_LP_VIC1,
    RSTSIG_LP_ADC7,
    RSTSIG_LP_WES,
    RSTSIG_LP_MRAM5             = MCU_RESET_SIG_ID(MCU_RESET_MODULE, 10U),
    RSTSIG_SAF_DEBUG            = MCU_RESET_SIG_ID(MCU_RESET_DEBUG, 0U),
    /* PRQA S 1535 1 */
} Mcu_ResetSignalApType;

/********************************************************************************************************
 *                                  Global Variable Declarations                                        *
 *******************************************************************************************************/

/* global reset */
extern const Mcu_ResetSigType rstctl_glb;

/* reset core */
extern const Mcu_ResetSigType rstsig_cr52p0;
extern const Mcu_ResetSigType rstsig_cr52p1;
extern const Mcu_ResetSigType rstsig_cr52p2;
extern const Mcu_ResetSigType rstsig_cr52p3;
extern const Mcu_ResetSigType rstsig_cr5_se;
extern const Mcu_ResetSigType rstsig_cr5_lp;
/**
 * @brief reset latent
 *
 * latent signals will reset automatically after power on.
 *
 */
extern const Mcu_ResetSigType rstsig_latent;

/*
 * @brief reset SAF mission
 *
 * reset mission signals will reset automatically after power on.
 *
 */
extern const Mcu_ResetSigType rstsig_saf_mission0;
extern const Mcu_ResetSigType rstsig_saf_mission1;
extern const Mcu_ResetSigType rstsig_saf_mission2;
extern const Mcu_ResetSigType rstsig_saf_mission3;
extern const Mcu_ResetSigType rstsig_saf_mission4;
extern const Mcu_ResetSigType rstsig_saf_mission5;
extern const Mcu_ResetSigType rstsig_saf_mission6;
extern const Mcu_ResetSigType rstsig_saf_mission7;
extern const Mcu_ResetSigType rstsig_saf_mission8;
extern const Mcu_ResetSigType rstsig_saf_mission9;
extern const Mcu_ResetSigType rstsig_saf_missionn10;

/* reset SAF module */
extern const Mcu_ResetSigType rstsig_seip;
extern const Mcu_ResetSigType rstsig_dma_sf1_rst0;
extern const Mcu_ResetSigType rstsig_dma_sf1_rst1;
extern const Mcu_ResetSigType rstsig_dma_sf2_rst0;
extern const Mcu_ResetSigType rstsig_dma_sf2_rst1;
extern const Mcu_ResetSigType rstsig_xspi1a;
extern const Mcu_ResetSigType rstsig_xspi1b;
extern const Mcu_ResetSigType rstsig_vic2;
extern const Mcu_ResetSigType rstsig_mb;
extern const Mcu_ResetSigType rstsig_epwm1;
extern const Mcu_ResetSigType rstsig_epwm2;
extern const Mcu_ResetSigType rstsig_epwm3;
extern const Mcu_ResetSigType rstsig_epwm4;
extern const Mcu_ResetSigType rstsig_etmr1;
extern const Mcu_ResetSigType rstsig_etmr2;
extern const Mcu_ResetSigType rstsig_etmr3;
extern const Mcu_ResetSigType rstsig_etmr4;
extern const Mcu_ResetSigType rstsig_ioc;
extern const Mcu_ResetSigType rstsig_dpe;
extern const Mcu_ResetSigType rstsig_xtrg1;
extern const Mcu_ResetSigType rstsig_xtrg2;
extern const Mcu_ResetSigType rstsig_enet1;
extern const Mcu_ResetSigType rstsig_enet2;
extern const Mcu_ResetSigType rstsig_sehc1;
extern const Mcu_ResetSigType rstsig_canfd3;
extern const Mcu_ResetSigType rstsig_canfd4;
extern const Mcu_ResetSigType rstsig_canfd5;
extern const Mcu_ResetSigType rstsig_canfd6;
extern const Mcu_ResetSigType rstsig_canfd7;
extern const Mcu_ResetSigType rstsig_canfd8;
extern const Mcu_ResetSigType rstsig_canfd9;
extern const Mcu_ResetSigType rstsig_canfd10;
extern const Mcu_ResetSigType rstsig_canfd11;
extern const Mcu_ResetSigType rstsig_canfd12;
extern const Mcu_ResetSigType rstsig_canfd13;
extern const Mcu_ResetSigType rstsig_canfd14;
extern const Mcu_ResetSigType rstsig_canfd15;
extern const Mcu_ResetSigType rstsig_canfd16;
extern const Mcu_ResetSigType rstsig_i2c2;
extern const Mcu_ResetSigType rstsig_i2c3;
extern const Mcu_ResetSigType rstsig_i2c4;
extern const Mcu_ResetSigType rstsig_spi3;
extern const Mcu_ResetSigType rstsig_spi4;
extern const Mcu_ResetSigType rstsig_spi5;
extern const Mcu_ResetSigType rstsig_spi6;
extern const Mcu_ResetSigType rstsig_spi7;
extern const Mcu_ResetSigType rstsig_spi8;
extern const Mcu_ResetSigType rstsig_spi9;
extern const Mcu_ResetSigType rstsig_spi10;
extern const Mcu_ResetSigType rstsig_spi11;
extern const Mcu_ResetSigType rstsig_spi12;
extern const Mcu_ResetSigType rstsig_spi13;
extern const Mcu_ResetSigType rstsig_spi14;
extern const Mcu_ResetSigType rstsig_uart3;
extern const Mcu_ResetSigType rstsig_uart4;
extern const Mcu_ResetSigType rstsig_uart5;
extern const Mcu_ResetSigType rstsig_uart6;
extern const Mcu_ResetSigType rstsig_uart7;
extern const Mcu_ResetSigType rstsig_uart8;
extern const Mcu_ResetSigType rstsig_uart9;
extern const Mcu_ResetSigType rstsig_uart10;
extern const Mcu_ResetSigType rstsig_uart11;
extern const Mcu_ResetSigType rstsig_uart12;
extern const Mcu_ResetSigType rstsig_uart13;
extern const Mcu_ResetSigType rstsig_uart14;
extern const Mcu_ResetSigType rstsig_uart15;
extern const Mcu_ResetSigType rstsig_uart16;
extern const Mcu_ResetSigType rstsig_uart17;
extern const Mcu_ResetSigType rstsig_uart18;
extern const Mcu_ResetSigType rstsig_uart19;
extern const Mcu_ResetSigType rstsig_uart20;
extern const Mcu_ResetSigType rstsig_sent;
extern const Mcu_ResetSigType rstsig_adc1;
extern const Mcu_ResetSigType rstsig_adc2;
extern const Mcu_ResetSigType rstsig_adc3;
extern const Mcu_ResetSigType rstsig_adc4;
extern const Mcu_ResetSigType rstsig_adc5;
extern const Mcu_ResetSigType rstsig_adc6;
extern const Mcu_ResetSigType rstsig_saci1;
extern const Mcu_ResetSigType rstsig_mram1;
extern const Mcu_ResetSigType rstsig_mram2;
extern const Mcu_ResetSigType rstsig_mram3;
extern const Mcu_ResetSigType rstsig_mram4;

/*
 * @brief reset LP mission
 *
 * reset mission signals will reset automatically after power on.
 *
 */
extern const Mcu_ResetSigType rstsig_lp_mission0;
extern const Mcu_ResetSigType rstsig_lp_mission1;
extern const Mcu_ResetSigType rstsig_lp_mission2;
extern const Mcu_ResetSigType rstsig_lp_mission4;

/* reset LP module */
extern const Mcu_ResetSigType rstsig_canfd1;
extern const Mcu_ResetSigType rstsig_canfd2;
extern const Mcu_ResetSigType rstsig_i2c1;
extern const Mcu_ResetSigType rstsig_spi1;
extern const Mcu_ResetSigType rstsig_spi2;
extern const Mcu_ResetSigType rstsig_uart1;
extern const Mcu_ResetSigType rstsig_uart2;
extern const Mcu_ResetSigType rstsig_vic1;
extern const Mcu_ResetSigType rstsig_adc7;
extern const Mcu_ResetSigType rstsig_wes;
extern const Mcu_ResetSigType rstsig_mram5;

/* general register */

#endif /* #if (defined(E3650)) */
#endif /* MCU_RESETSIG_H */

/* End of file */
